package com.dhl.cloud.core.service;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dhl.cloud.core.dao.DicinfoMapper;
import com.dhl.cloud.core.dao.DictypeMapper;
import com.dhl.cloud.core.entity.Dictype;

@Service
public class DictypeService {

    @Autowired
    private DictypeMapper dictypeMapper;
    @Autowired
	private DicinfoMapper dicinfoMapper;

	public boolean deleteByPrimaryKey(Integer id){
		return dictypeMapper.deleteByPrimaryKey(id)==1;
	};

	public boolean insert(Dictype record){
		if (record.getId() == null){
			return dictypeMapper.insert(record)==1;
		}else{
			return dictypeMapper.updateByPrimaryKey(record)==1;
		}
	};

	public boolean insertSelective(Dictype record){
		return dictypeMapper.insertSelective(record)==1;
	};

	public Dictype selectByPrimaryKey(Integer id){
		return dictypeMapper.selectByPrimaryKey(id);
	};

	public boolean updateByPrimaryKeySelective(Dictype record){
		return dictypeMapper.updateByPrimaryKeySelective(record)==1;
	};

	public boolean updateByPrimaryKey(Dictype record){
		return dictypeMapper.updateByPrimaryKey(record)==1;
	};

	public List<Dictype> getDicTypeList(){
		return dictypeMapper.getDicTypeList();
	}

	@Transactional
	public Boolean deleteDicType(Integer id) {
		Dictype dictype = dictypeMapper.selectByPrimaryKey(id);
		if (null!=dictype){
			dicinfoMapper.deleteBySystemstate(dictype.getSystemstate());
			dictypeMapper.deleteByPrimaryKey(id);
		}
		return true;
	}
}
